package cn.lzm.protocol;

import lombok.Getter;

/**
 * @author lzm
 * @Date 2024/11/5
 * @description 协议状态枚举
 */
@Getter
public enum ProtocolStatusEnum {

    OK("ok", 20),
    BAD_REQUEST("bad request", 30),
    BAD_RESPONSE("bad response", 40);

    private final String text;

    private final int value;

    ProtocolStatusEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据value获取枚举
     *
     * @param value
     * @return
     */
    public static ProtocolStatusEnum getStatusByValue(int value) {
        for (ProtocolStatusEnum statusEnum : ProtocolStatusEnum.values()) {
            if (statusEnum.getValue() == value) {
                return statusEnum;
            }
        }
        return null;
    }


}
